import { h, resolveComponent } from 'vue'
import { createRouter, createWebHashHistory,RouteRecordRaw } from 'vue-router'

const RouteView = {
  render: () => h(resolveComponent('router-view'))
}

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Index',
    component: () => import('@/views/index/index.vue'),
   // redirect:'/farmlandData',
   redirect:'/user/login',
   
    meta: {
      title: '主页'
    },
    children:[
      {
        path: '/farmlandData',
        name: 'farmlandData',
        component: RouteView,
        redirect:'/farmlandData/statistics',
        meta: {
          title: '农场地图'
        },
        children:[
          {
            path: '/farmlandData/statistics',
            name: 'farmlandData_statistics',
            component: () => import('@/views/farmlandData/statistics.vue'),
            meta: {
              title: '农场地图统计'
            }
          },
          {
            path: '/farmlandData/land',
            name: 'farmlandData_land',
            component: () => import('@/views/farmlandData/land.vue'),
            meta: {
              title: '土地确权'
            }
          },
          {
            path: '/farmlandData/monitor',
            name: 'farmlandData_monitor',
            component: () => import('@/views/farmlandData/monitor.vue'),
            meta: {
              title: '遥感长势监测'
            }
          }
        ]
      },
      
      {
        path: '/plantingType',
        name: 'plantingType',
        component: RouteView,
        redirect:'/plantingType/dataStatistics',
        meta: {
          title: '农场信息'
        },
        children:[
          {
            path: '/plantingType/detail',
            name: 'plantingType_detail',
            component: () => import('@/views/plantingType/detail.vue'),
            meta: {
              title: '种植地块'
            }
          },
          {
            path: '/plantingType/dataStatistics',
            name: 'plantingType_dataStatistics',
            component: () => import('@/views/plantingType/dataStatistics.vue'),
            meta: {
              title: '数据统计'
            }
          },
          {
            path: '/plantingType/plotDetails',
            name: 'plantingType_plotDetails',
            component: () => import('@/views/plantingType/plotDetails.vue'),
            meta: {
              title: '地块详情'
            }
          },
          {
            path: '/plantingType/typeStatistics',
            name: 'plantingType_typeStatistics',
            component: () => import('@/views/plantingType/typeStatistics.vue'),
            meta: {
              title: '种植类型统计'
            }
          }
        ]
      },
      {
        path: '/cultivationMode',
        name: 'cultivationMode',
        component: RouteView,
        redirect:'/cultivationMode/dataStatistics',
        meta: {
          title: '基础设施管理'
        },
        children:[
          {
            path: '/cultivationMode/dataStatistics',
            name: 'cultivationMode_dataStatistics',
            component: () => import('@/views/cultivationMode/dataStatistics.vue'),
            meta: {
              title: '数据统计'
            }
          },
          {
            path: '/cultivationMode/plotDetails',
            name: 'cultivationMode_plotDetails',
            component: () => import('@/views/cultivationMode/plotDetails.vue'),
            meta: {
              title: '地块详情'
            }
          },
          {
            path: '/cultivationMode/modeStatistics',
            name: 'cultivationMode_modeStatistics',
            component: () => import('@/views/cultivationMode/modeStatistics.vue'),
            meta: {
              title: '栽培模式统计'
            }
          }
        ]
      },
      {
        path: '/growthAnalysis',
        name: 'growthAnalysis',
        component: RouteView,
        redirect:'/growthAnalysis/fieldStatistics',
        meta: {
          title: '长势分析'
        },
        children:[
          {
            path: '/growthAnalysis/fieldStatistics',
            name: 'growthAnalysis_fieldStatistics',
            component: () => import('@/views/growthAnalysis/fieldStatistics.vue'),
            meta: {
              title: '在田统计'
            }
          },
          {
            path: '/growthAnalysis/plotDetails',
            name: 'growthAnalysis_plotDetails',
            component: () => import('@/views/growthAnalysis/plotDetails.vue'),
            meta: {
              title: '地块详情'
            }
          },
          {
            path: '/growthAnalysis/monitor',
            name: 'growthAnalysis_monitor',
            component: () => import('@/views/growthAnalysis/monitor.vue'),
            meta: {
              title: '遥感长势监测'
            }
          },
          {
            path: '/growthAnalysis/analysisReport',
            name: 'growthAnalysis_analysisReport',
            component: () => import('@/views/growthAnalysis/analysisReport.vue'),
            meta: {
              title: '长势分析报告'
            }
          }
        ]
      },
      {
        path: '/farmingMachinery',
        name: 'farmingMachinery',
        component: RouteView,
        redirect:'/farmingMachinery/fieldStatistics',
        meta: {
          title: '农机管理'
        },
        children:[
          {
            path: '/farmingMachinery/fieldStatistics',
            name: 'farmingMachinery',
            component: () => import('@/views/farmingMachinery/fieldStatistics.vue'),
            meta: {
              title: '农机列表'
            }
          }
        ]
      },
      {
        path: '/inputManagement',
        name: 'inputManagement',
        component: RouteView,
        redirect:'/inputManagement/flagDomain',
        meta: {
          title: '农资管理'
        },
        children:[
          {
            path: '/inputManagement/flagDomain',
            name: 'inputManagement_flagDomain',
            component: () => import('@/views/inputManagement/flagDomain.vue'),
            meta: {
              title: '旗域统计'
            }
          },
          {
            path: '/inputManagement/massifData',
            name: 'inputManagement_massifData',
            component: () => import('@/views/inputManagement/massifData.vue'),
            meta: {
              title: '地块数据'
            }
          },
          {
            path: '/inputManagement/massifRank',
            name: 'inputManagement_massifRank',
            component: () => import('@/views/inputManagement/massifRank.vue'),
            meta: {
              title: '地块排行'
            }
          },
        ]
      },
      {
        path: '/climateSuitability',
        name: 'climateSuitability',
        component: RouteView,
        redirect:'/climateSuitability/meteorology',
        meta: {
          title: '气候适宜度'
        },
        children:[
          {
            path: '/climateSuitability/meteorology',
            name: 'climateSuitability_meteorology',
            component: () => import('@/views/climateSuitability/meteorology.vue'),
            meta: {
              title: '气象适宜度'
            }
          },
          {
            path: '/climateSuitability/disaster',
            name: 'climateSuitability_disaster',
            component: () => import('@/views/climateSuitability/disaster.vue'),
            meta: {
              title: '灾害防范'
            }
          },
          {
            path: '/climateSuitability/realtimeData',
            name: 'climateSuitability_realtimeData',
            component: () => import('@/views/climateSuitability/realtimeData.vue'),
            meta: {
              title: '实时数据'
            }
          },
          {
            path: '/climateSuitability/climate',
            name: 'climateSuitability_climate',
            component: () => import('@/views/climateSuitability/climate.vue'),
            meta: {
              title: '气候适宜指数'
            }
          },
          {
            path: '/climateSuitability/advice',
            name: 'climateSuitability_advice',
            component: () => import('@/views/climateSuitability/advice.vue'),
            meta: {
              title: '农事建议'
            }
          }
        ]
      },
      // {
      //   path: '/userInfo',
      //   name: 'userInfo',
      //   component: RouteView,
      //   redirect:'/userInfo/manger',
      //   meta: {
      //     title: '个人信息'
      //   },
      //   children:[
      //     {
      //       path: '/userInfo/manger',
      //       name: 'userInfo_manger',
      //       component: () => import('@/views/growthAnalysis/water.vue'),
      //       meta: {
      //         title: '数据统计'
      //       }
      //     },
      //   ]
      // },
      {
        path: '/water',
        name: 'water',
        component: RouteView,
        redirect:'/growthAnalysis/water',
        meta: {
          title: '土壤水质数据'
        },
        children:[
          {
            path: '/growthAnalysis/water',
            name: 'growthAnalysis_water',
            component: () => import('@/views/userInfo/index.vue'),
            
            meta: {
              title: '土壤水质数据'
            }
          },
        ]
      },
      {
        path: '/plan',
        name: 'plan',
        component: RouteView,
        redirect:'/plan/list',
        meta: {
          title: '农事计划'
        },
        children:[
          {
            path: '/plan/list',
            name: 'plan_list',
            component: () => import('@/views/plan/list.vue'),
            meta: {
              title: '农事计划列表'
            }
          },
          {
            path: '/plan/audit',
            name: 'plan_audit',
            component: () => import('@/views/plan/audit.vue'),
            meta: {
              title: '农事计划审核'
            }
          },
          {
            path: '/plan/template',
            name: 'plan_template',
            component: () => import('@/views/plan/template.vue'),
            meta: {
              title: '农事计划模板'
            }
          },
          {
            path: '/plan/info',
            name: 'plan_info',
            component: () => import('@/views/plan/info.vue'),
            meta: {
              title: '农事计划信息'
            }
          },
          {
            path: '/plan/addPlan',
            name: 'plan_addPlan',
            component: () => import('@/views/plan/addPlan.vue'),
            meta: {
              title: '新增农事计划'
            }
          },
          {
            path: '/plan/detail',
            name: 'plan_detail',
            component: () => import('@/views/plan/detail.vue'),
            meta: {
              title: '农事计划详情'
            }
          },
          {
            path: '/plan/addTemplate',
            name: 'plan_addTemplate',
            component: () => import('@/views/plan/addTemplate.vue'),
            meta: {
              title: '农事计划详情'
            }
          },
        ]
      }
    ]
  },
  {
    path: '/user/login',
    name: 'Login',
    component: () => import('../views/login/login.vue')
  },
  {
    path: '/user/subPage',
    name: 'subPage',
    component: () => import('../views/login/subPage.vue')
  },
  {
    path: '/user/login-callback',
    name: 'LoginCallBack',
    component: () => import('../views/login/loginCallBack.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
